<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<script type="text/javascript" >

$(function(){
	$('#inboxGrid').datagrid({
	    url: ctx + '/pof/Mail!findByPage.action',
	    fit: true,
	    pagination: true,
	    queryParams:{'folderId':1},
	    toolbar:'#button_index',
	    rownumbers: true,
	    idField: 'sid',
	    rowStyler: function(index,row){
	    	//未读
	    	if(0==row.readFlag){
	    		return "font-weight:bold;";
	    	}
	    },
	    onDblClickRow :function(rowIndex,rowData){
	    	CQOA.load('extendDiv',ctx+'/pof/Mail!detail.action',{'entity.sid':rowData.sid},function(){
				CQOA.hideDiv('mainDiv');
				CQOA.showDiv('extendDiv');
				$('#gridId').val('inboxGrid');
			});
	    }
	});
	
	
	$('#inboxDel').bind('click',function(){
		var row = $('#inboxGrid').datagrid('getSelected');
		if (!row) {
			$.messager.show({
				msg : '请选择一条数据'
			});
			return false;
		}
		$.messager.confirm('提示信息','你确定要删除这条数据?',function(o){
			if(o){
				postcommit(ctx+'/pof/Mail!delete.action',{'entity.sid':row.sid},function(rel){
					if(rel.success){
						$('#inboxGrid').datagrid('reload');
					}
					$.messager.show({
						msg : rel.msg
					});
				});
			}
		});
	});
	
	$('#readMail').bind('click',function(){
		$('#inboxGrid').datagrid('reload',{
    		'folderId':1,
    		'isRead':1,
    		'entity.title':$('#stitle').searchbox('getValue')
    	});
	})
	
	$('#unReadMail').bind('click',function(){
		$('#inboxGrid').datagrid('reload',{
    		'folderId':1,
    		'isRead':0,
    		'entity.title':$('#stitle').searchbox('getValue')
    	});
	})
	
	$('#allMail').bind('click',function(){
		$('#inboxGrid').datagrid('reload',{
    		'folderId':1,
    		'entity.title':$('#stitle').searchbox('getValue')
    	});
	})
	
	$('#stitle').searchbox({
	    searcher:function(value,name){
	    	$('#inboxGrid').datagrid('reload',{
	    		'folderId':1,
	    		'entity.title':value
	    	});
	    },
	    prompt:'请输入标题'
	});
});

</script>
<div id="mainDiv" class="easyui-layout" fit="true" border="false">
	        <div id="easyui-title" style="display:none">
	            	收件箱
	        </div>
           <div class="top_toolbar_div" region="north" border="false">                
                 <input id="stitle" style="width:300px" ></input>
            </div>
            <div id="button_index" class="top_toolbar_button_div" border="false">
                    <a href="#" class="easyui-linkbutton"  id="inboxDel">删除</a>
                    <a href="#" style="color: blue;" id="readMail">已读</a>
                    <a href="#" style="color: blue;" id="unReadMail">未读</a>
                    <a href="#" style="color: blue;" id="allMail">全部</a>
            </div>
            <div  region="center" border="false">
	           <table id="inboxGrid" title="邮件数据" border="false" fit="true" >
	               			<thead>
			                   <tr>
			                   	  <!-- 
			                      <th field="sid"  width="50">SID</th>
			                       -->
			                      <th checkbox="true"  width="50"></th>
			                      <th field="senderCname"  width="100">发件人</th>
			                      <th field="title"  width="200">标题</th>
			                      <th field="sendTime"  width="150">时间</th>
			                   </tr>
	               			</thead>
	       	 	</table>
           </div>
</div>
<div id="extendDiv" class="easyui-panel" style="display:none;" fit="true" border="false"></div>


